<template>
  <div>
      <div class="myHeart" v-for="(value,index) in desMessage" :key="index">
        <div class="myHeart-header">
            <div class="myHeart-message">
                <van-image :src="require('../assets/header.jpg')" round>
                    <template v-slot:loading>
                        <van-loading type="spinner" size="20" />
                    </template>
                </van-image>
            </div>
            <div>
               <div class="myHeart-name"> <span>Coldfront</span></div>
               <div class="myHeart-time"> <span >{{value.time|changeTime}}&nbsp;</span></div>
            </div>
        </div>
        <div class="myHeart-des">
          <div style="">
             <p>{{value.desText}}</p>
          </div>
        </div>

        <div class="myHeart-machine">
           <div> <span>Windows10 Google Brower</span></div>
           <div class="zan"> 
                <loveAdd :index="value._id"/>
                <span>{{value.count}}</span>
           </div>
     </div>
        
    </div>
  
  </div>
</template>

<script>
import loveAdd from "./loveAdd"
import axios from "axios"
export default {
    name:"myAction",
    components:{
        loveAdd
    },
    data(){
        return{
        }
    },
    methods:{
       
    },
    mounted(){
        axios.get("/blog/users").then((value)=>{
           this.$store.state.desMessage=value.data
              // console.log(this.$store.state.desMessage)
       }).catch(err=>{
           console.log("出错了---"+err)
       })
       
    },           
   computed:{
       desMessage:function(){
            return this.$store.state.desMessage.reverse();
       }
   },
   filters:{
       changeTime:(value)=>{
           var date=new Date(value)
           return `${date.getFullYear()}年${date.getMonth()+1}月${date.getDate()}日`
       }
   }

}
</script>

<style>
.myHeart{
     background-color: #eee;
}
.myHeart .myHeart-header,.myHeart-des,.myHeart-machine{
      margin:  0 15px;
    margin-top: 1.5rem;
}
.myHeart-header{
    display:flex;
    flex-direction: row;
   
}
.myHeart-header .van-image__img{
    height: 5rem;
    width: auto;
    margin: 0 10px;
}
.myHeart-name{
    line-height:20px;
    height: 20px;
    margin-top: 5px;
}
.myHeart-time{
   line-height:20px;
    height: 20px;
   margin-top:5px;
   font-size: 10px;
   color: #666;
}
.myHeart-des{
    background-color:#fff;
    height:100%;
    line-height:100%;
    
}
.myHeart-des p{
    padding: 1rem;
    color: #666;
    line-height:2rem;
    letter-spacing: 2px;

}
.myHeart-machine{
    line-height: 40px;
    height: 40px;
    color: #666;
     font-size: 10px;
     display: flex;
     flex-direction:row;
     
}
.myHeart-machine .zan{
    margin-left: auto;
    margin-right: 10px;
    font-size: 1.5rem;
}
.myHeart-machine .zan span{
    margin: 0 4px;
}
</style>